package com.qf.dao;

import com.qf.pojo.EmpManager;
import com.qf.utils.DataSourceUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

/**
 * @author 千锋健哥
 */
public class EmpManagerDaoImpl implements EmpManagerDao{

    //1. 创建全局的QueryRunner对象
    private QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());

    @Override
    public EmpManager findManagerByUserName(String userName) {
        try {
            String sql = "select * from empmanager where username=?";
            EmpManager empManager = queryRunner.query(sql, new BeanHandler<EmpManager>(EmpManager.class), userName);
            return empManager;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

}
